package com.itboye.jinpuyiyuan.utils;


import android.os.AsyncTask;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.itboye.jinpuyiyuan.bean.OnlineBean;
import com.itboye.jinpuyiyuan.bean.UserInfoBean;
import com.itboye.jinpuyiyuan.presenter.BranchAddressPresenter;
import com.itboye.jinpuyiyuan.utils.sputil.Const;
import com.itboye.jinpuyiyuan.utils.volley.ResultEntity;

import java.util.Observable;
import java.util.Observer;

/**
 * Created by Administrator on 2018/6/28 0028.
 */

public class MyAsyTask extends AsyncTask<String,Void,String> implements Observer {
    String baichuanId;
    TextView nickName;
    private    BranchAddressPresenter presenter;
    public MyAsyTask(String baichuanId, TextView nickName){
        this.baichuanId=baichuanId;
        this.nickName=nickName;
    }
    @Override
    protected String doInBackground(String... strings) {

        presenter = new BranchAddressPresenter(this);
        //查询用户信息
        presenter.queryOnlineStatus(baichuanId);
        return null;
    }


    @Override
    public void update(Observable o, Object arg) {
        ResultEntity entity= (ResultEntity) arg;
        if (entity!=null){

            if (entity.getEventType()== BranchAddressPresenter.By_UserProfile_getOnlineStatus_success){//查询在线状态获取 uid

                presenter.getPersonInfo(((OnlineBean)entity.getData()).getUid());
            }else if (entity.getEventType()== BranchAddressPresenter.By_UserProfile_getOnlineStatus_fail){


            }else if (entity.getEventType()== BranchAddressPresenter.By_UserIdCard_info_success){//获取用户信息
                UserInfoBean userInfo= (UserInfoBean) entity.getData();
//                String uid=userInfo.getUid();

                nickName.setText(userInfo.getNickname());


            }else if (entity.getEventType()== BranchAddressPresenter.By_UserIdCard_info_fail){//获取信息


            }
        }
    }
}
